

#ifndef STOREXENGINE_H_
#define STOREXENGINE_H_

#include "../Memory/MemoryWrapper.h"
#include "../Memory Manager/MemoryManager.h"
#include "../Memory Manager/SerialMemoryManager.h"
#include "../Memory Manager/SerialMemoryManager2.h"
#include "../Memory Manager/ParallelMemoryManager.h"
#include "../Memory Manager/Memory Tables/MemoryTable.h"
#include "../Memory Manager/Memory Tables/PriorityMemoryTable.h"
#include "../Memory Manager/Memory Tables/AllocationMemoryTable.h"
#include "../Engine/TRexEngine.h"
#include "ConfigHandler.h"
#include "../Packets/PubPkt.h"
#include "../Packets/RulePkt.h"
#include "../Packets/SubPkt.h"
#include "../Packets/UnSubPkt.h"
#include "../Engine/ResultListener.h"
#include "../Subscription Manager/SubscriptionManager.h"
#include "OutputListener.h"
#include "../Subscription Manager/OMPInterface.h"
#include "../Memory Manager/Memory Tables/EventMemoryTable.h"
#include "../Memory Manager/Memory Tables/FIFOMemoryTable.h"
#include "../Memory Manager/Memory Tables/OCMMemoryTable.h"
#include "../Test/Producer.h"


class StorexEngine {

public:

	StorexEngine(ConfigHandler* parConfigHandler, OutputListener* outputListener);

	virtual ~StorexEngine();

	void processRulePkt(RulePkt *pkt);

	void processSubPkt(Inbox *inbox);

	void processUnSubPkt(Inbox *inbox);

	void processPubPkt(PubPkt *pkt);

private:

	class TRexResultListener: public ResultListener{
		StorexEngine &parent;
		std::set<PubPkt *> eventsSet;
	public:
		TRexResultListener(StorexEngine& s): parent(s) { }
		virtual ~TRexResultListener() { }
		std::set<PubPkt *> & getEventsSet() { return eventsSet; }
		void handleResult(set<PubPkt *> &genPkts, double procTime);
	};

	MemoryWrapper *memory;

	MemoryTable *memoryTable;
//	EventMemoryTable *eventMemoryTable;
	OCMMemoryTable *ocmMemoryTable;

	MemoryManager *memoryManager;

	TRexEngine *trexEngine;
	TRexResultListener resultListener;
	std::set<int> recursiveTypes;

	SubscriptionManagerType subsManagerType;
	SubscriptionManager *subsManager;

	OutputListener *outputListener;

	Timer *timer;

	std::set<RulePkt*> ruleSet;

};




#endif /* STOREXENGINE_H_ */
